home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3244 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.7 KB  |  66 lines

  1. Path: wv.mentorg.com!bloom
  2. From: bloom@wv.mentorg.com (Scott Aron Bloom)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: cin and floats
  5. Date: 23 Jan 1996 00:33:48 GMT
  6. Organization: Mentor Graphics, Wilsonville, Oregon, USA
  7. Distribution: world
  8. Message-ID: <4e1adc$dvh@hpbab.wv>
  9. References: <4d9d0g$5s0@sol.zynet.net>
  10. NNTP-Posting-Host: glock.wv
  11.  
  12. In article <4d9d0g$5s0@sol.zynet.net>, damage@nashuauk.zynet.co.uk (Damage) writes:
  13. |> HELP!  I can't seem to use "cin" to input into floating point numbers.
  14. |> Whenever I enter a decimal number I just get "Floating Point
  15. |> Overflow".  Integers are fine, it's also fine if I enter whole number
  16. |> into the float variable (and yes I'm positive that I've declared the
  17. |> variable correctly).
  18. |> 
  19. |> I am using Turbo C++ 4.5 for Windows under Win '95.
  20. |> 
  21. |> eg:
  22. |>     float x;
  23. |> 
  24. |>     cout << "Enter Real Number: ";
  25. |>     cin >> x;
  26. |> 
  27. |> Any help would be most appreciated.
  28. |> 
  29. |> Cheers.  Shane.
  30. |> ...~daMage~...
  31. |> 
  32.  
  33.  
  34. I have a feeling it has to do with the input mechinism in
  35. win 95.  Having never programed in win95, but doing some
  36. programming in Win 3.11.
  37.  
  38. Do a help search in BC++ for input and see what it has to say.
  39.  
  40.  
  41. FWIW, i tried the followin code on a UNIX system, and it worked
  42. without a hitch:
  43.  
  44. #include <iostream.h>
  45.  
  46. main()
  47. {
  48.    float x;
  49.  
  50.    cout << "Enter Real Number: ";
  51.    cin >> x;
  52.  
  53.    cout << "You entered: " << x << endl;
  54. }
  55.  
  56.  
  57. Scott
  58. -- 
  59. ----------------------------------------------------------
  60. Scott Aron Bloom              email:  bloom@wv.mentorg.com
  61. Mentor Graphics Corporation   main:   (503) 685-7000
  62. 8005 S.W. Boeckman Road C/4   direct: (503) 685-7996
  63. Wilsonville, OR 97070-7777    fax:    (503) 685-1268
  64. ===============  Silicon Systems Division  ===============
  65. ----------------------------------------------------------
  66.